home *** CD-ROM | disk | FTP | other *** search
/ Champak 49 / Volume 49 - JOGO DISK .iso / Games / honeytrouble.swf / scripts / __Packages / Grid.as < prev   
Encoding:
Text File  |  2007-09-27  |  1.1 KB  |  44 lines

  1. class Grid
  2. {
  3.    var width;
  4.    var xNum;
  5.    var yNum;
  6.    var area;
  7.    function Grid(__width, w, h, arr)
  8.    {
  9.       this.width = __width;
  10.       this.xNum = w;
  11.       this.yNum = h;
  12.       this.area = arr;
  13.    }
  14.    function push(x, y, mc, name)
  15.    {
  16.       var _loc3_ = undefined;
  17.       var _loc2_ = undefined;
  18.       var _loc6_ = undefined;
  19.       _loc3_ = Math.floor(x / this.width);
  20.       _loc2_ = Math.floor(y / this.width);
  21.       this.area[_loc3_][_loc2_][name].push(mc);
  22.    }
  23.    function pop(x, y, mc, name)
  24.    {
  25.       var _loc4_ = undefined;
  26.       var _loc3_ = undefined;
  27.       var _loc2_ = undefined;
  28.       _loc4_ = Math.floor(x / this.width);
  29.       _loc3_ = Math.floor(y / this.width);
  30.       _loc2_ = 0;
  31.       while(_loc2_ < this.area[_loc4_][_loc3_][name].length)
  32.       {
  33.          if(this.area[_loc4_][_loc3_][name][_loc2_] == mc)
  34.          {
  35.             trace(this.area);
  36.             this.area[_loc4_][_loc3_][name].splice(_loc2_,1);
  37.             trace(this.area);
  38.             break;
  39.          }
  40.          _loc2_ = _loc2_ + 1;
  41.       }
  42.    }
  43. }
  44.